﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using KPIS.GERP.GHRMS.BLL;
using KPIS.GERP.GHRMS.IBLL;
using KPIS.GERP.GHRMS.MODEL;
using KPIS.GERP.GHRMS.APP.Classes;
using _WebShared.Classes;
using System.IO;

namespace KPIS.GERP.GHRMS.APP.App_UI.Forms
{
    public partial class PS_EmployeeLists : System.Web.UI.Page
    {
        private IEmployeeBLL empBLL = new EmployeeBLL();
        private IEmployeeTypeBLL et = new EmployeeTypeBLL();
        private IEmployeeStatusBLL statusBLL = new EmployeeStatusBLL();
        private IJobSiteBLL job = new JobSiteBLL();
        private IPositionBLL posBLL = new PositionBLL();
        private IClassBLL classBLL = new ClassBLL();
        Main main = new Main();


        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                bindEmpType();
            }
        }
        private void bindEmpType()
        {
            try
            {
                IList<EmployeeTypeInfo> infoList = et.ListEmployeeTypes();
                ddlEmployeeType.DataSource = infoList;
                ddlEmployeeType.DataBind();

            }
            catch
            {

            }
        }
        private void LoadGrid()
        {
            IList<EmployeeInfo> infoList = empBLL.ListEmployeeByTypes(ddlEmployeeType.SelectedValue, "", "");

            RadGrid1.DataSource = infoList;// emp.SelectGrid(strEmpTypeSeq, strEmpStatusSeq, "1", "working_job_site_ref, pos_ref");

            //GridGroupByExpression g = new GridGroupByExpression(RadGrid1.Columns[5]);
            //RadGrid1.MasterTableView.GroupByExpressions.Add(g);
            RadGrid1.DataBind();

        }

        protected void CheckDateValid(object source, ServerValidateEventArgs args)
        {
            if (!DateTimeX.IsValidDmyDate(args.Value, true))
            {
                args.IsValid = false;
            }
        }

        protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridNestedViewItem)
            {
                //e.Item.FindControl("InnerContainer").Visible = ((GridNestedViewItem)e.Item).ParentItem.Expanded;
            }

        }
        protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
        {
            if (e.CommandName == RadGrid.ExpandCollapseCommandName)
            {
                Session["emp_seq"] = ((Label)((GridDataItem)e.Item).ChildItem.FindControl("lblEmpSeq")).Text;
            }

            IList<EmployeeInfo> infoList = empBLL.ListEmployeeByTypes(ddlEmployeeType.SelectedValue, "", "");
            RadGrid1.DataSource = infoList;
            
        }

        protected void RadGrid1_PageIndexChanged(object source, GridPageChangedEventArgs e)
        {

        }

        protected void ddlEmployeeType_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            LoadGrid();
        }
    }
}
